package dw2;
import java.awt.*;

public class HUD
{
    String word = "Score";
    Font f = new Font("Dungeon", 1, 25);
    Font d = new Font("Dungeon",1, 10);
    int d_count = 0;
    int l_count = 1;
    int s_count = 0;
    //int levelScore_change = 2500;
    //int boss_change = 5000;
    int levelScore_change = 1000;
    int boss_change = 3000;
    int cCount = 0;
    int sValue = 0;
    int lvl = 0;
    boolean leveled = false;
    boolean highScore = false;

    
    public HUD()
    {
    }

    public void draw(Graphics g,Worm player1)
    {
 
            double life = 0;
            g.setFont(d);
            g.setColor(Color.red);
            g.fillRect(10, 10, 102, 20);
            g.setColor(Color.gray);
            g.drawRect(10, 10, 102, 20);

            life = (100 / player1.getMaxHP()) * player1.getHP();
            g.setColor(Color.green);
            g.fillRect(11, 11, (int)life, 19);

            g.setColor(Color.black);
            String value = Integer.toString((int)life);
            g.drawString(value,50,25);

            drawScore(g,player1);

            //DISLAY LEVEL
             if(player1.getScore() == 0 && l_count < 100 && lvl == 0){
                 //System.out.println(l_count);
                 l_count++;
                 if(l_count < 150){
                    g.setColor(Color.yellow);
                    g.drawString("LEVEL 1: THE MILITARY!!!", 280, 110);
                }
             }else if(!leveled && player1.getScore() < levelScore_change && lvl == 0){
                //System.out.println("NOOOOO");
                l_count = 0;
                lvl = 1;
             }

             
            if(player1.getScore() >= levelScore_change && leveled && l_count< 150 && lvl == 1){
                l_count++;
                System.out.println(l_count);
                 if(l_count < 150){
                    g.setColor(Color.yellow);
                    g.drawString("LEVEL 2: ALIENS!!! HP+20", 280, 110);
                                 
                }else {
                    leveled = false;
                    player1.hurtWorm(-20);
                }
            }
            else if(!leveled && l_count == 150 && lvl == 1){
                //System.out.println("HEEEEEEEEEEEEEEE");
                l_count = 0;
                leveled = false;
                lvl = 2;
             }

            /*System.out.println(lvl);
            System.out.println(leveled);
            System.out.println(l_count);*/

            if(player1.getScore() >= boss_change && leveled && l_count< 150 && lvl == 2){
                l_count++;
                 if(l_count < 150){
                    g.setColor(Color.yellow);
                    g.drawString("WARNING: BOSS! HP+20", 280, 110);
                  

                }else{
                    leveled = false;
                    player1.hurtWorm(-20);
                }
            }
          

            //DISPLAY HP+10
            if(player1.getHit()){
                g.setColor(Color.green);
                g.drawString("HP + 10",330,150);
                d_count++;
                if(d_count == 50){
                    player1.resetHit();
                    d_count=0;
                }
            }
            
            
            if(player1.showComboText){
                g.setColor(Color.green);
                g.drawString(player1.comboManager.getComboText(),240,50);
                cCount++;
                if(cCount == 100){
                    player1.showComboText = false;
                    cCount = 0;
                    
                }
            }
             
             

            g.setColor(Color.red);

    }

    public void drawScore(Graphics g,Worm player1){
        String score = Integer.toString(player1.getScore());
        g.setColor(Color.red);
        g.setFont(f);
        g.drawString(word,450,75);
        g.drawString(score,700,75);                 //Display Current Player's score
        g.setColor(Color.gray);
        g.drawString("Highest Score ",450,50 );     //Display Current HighScore
        g.drawString(Main.highestScore,700, 50);
        int highscore = Integer.parseInt(Main.highestScore);
        int currentscore = Integer.parseInt(score);
        if(currentscore > highscore){
            if(s_count < 85){
                g.setColor(Color.yellow);
                g.drawString("NEW HIGH SCORE!",450,150 );
                if(!highScore) {
                    player1.comboManager.excellentSound.play();
                    highScore = true;
                }
                s_count++;
            }
        }else{
            s_count = 0;
        }
     }
     public void levelUp(){
         leveled = true;
     }
}
